package org.create.builder;

import org.create.utils.IoTool;
import org.create.utils.LogTool;

import java.io.File;
import java.io.IOException;

import static org.create.bean.Constants.*;


public class BuildTest {
    private static final String[] tests = {"MapperTest"}; // 存储文件

    private static void initialDir() throws IOException {
        File dir = new File(TEST_ROOT);
        boolean r = dir.mkdirs();
        LogTool.printLog(r, "新建目录", dir);
        for (String test : tests) {
            writePackage(dir, test, test);
        }
    }

    private static void writePackage(File dir, String resource, String target) throws IOException {
        File file = new File(dir, target + JAVA_SUFFIX);
        boolean du = file.createNewFile();
        LogTool.printLog(du, "新建文件", file);
        execute(resource, file);
    }

    private static void execute(String resource, File file) throws IOException {
        IoTool.copy(LOCAL_RESOURCE_PATH + resource, file, 4080, false);
    }

    public static void run() {
        try {
            initialDir();
        } catch (Exception e) {
            LogTool.printError(e);
        }
    }
}
